package fw.qaz.asmx.reader;

import android.app.AlertDialog;
import android.app.Application;
import android.widget.Toast;

import com.squareup.leakcanary.LeakCanary;

import fw.qaz.asmx.reader.utils.BookShelfUtil;

public class MyApplication extends Application implements Thread.UncaughtExceptionHandler
{
    @Override public void onCreate()
    {
        super.onCreate();
        Thread.currentThread().setUncaughtExceptionHandler(this);
        LeakCanary.install(this);
        //
        BookShelfUtil.initBookShelfFile(this);
        //
//        if (SettingCenter.isFirstUse(this))
//        {
//            SettingCenter.setFirstUse(this, false);
//        }
    }

    @Override public void uncaughtException(Thread thread, Throwable ex)
    {
        new AlertDialog.Builder(this)
                .setTitle("崩溃报告：")
                .setMessage(ex.getLocalizedMessage() + "###" + ex.getMessage())
                .show();
        Toast.makeText(this, thread.getId() + "号线程发生异常！", Toast.LENGTH_SHORT).show();
    }
}
